<?php

namespace App\Http\Requests;

use App\ViewModels\ConnectionsViewModel;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class AddServerRequest extends FormRequest
{
    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            'ip' => ['required', 'ip', 'unique:servers,ip_address'],
            'port' => ['required', 'integer'],
            'name' => ['required', 'string'],
            'connections' => ['required', 'array'],
            'connections.*' => Rule::in(ConnectionsViewModel::make()->getConnectionNames()),
        ];
    }
}
